//
//  QZMyVideoCell.m
//  shortvideoplay
//
//  Created by adam on 2024/6/23.
//

#import "QZMyVideoCell.h"

@implementation QZMyVideoCell
{
    UIImageView * v_image;
    UIImageView * v_foot;
    UILabel * v_top;
    UIImageView * v_type;
    UILabel * v_number;
    UIView * v_seeView;
    UILabel * v_seeLabel;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        v_image = [[UIImageView alloc]init];
        v_image.contentMode = UIViewContentModeScaleAspectFill;
        v_image.layer.cornerRadius = 5;
        v_image.clipsToBounds = YES;
        [self addSubview:v_image];
        
        v_foot = [[UIImageView alloc]init];
        v_foot.contentMode = UIViewContentModeScaleToFill;
        v_foot.clipsToBounds = YES;
        v_foot.image = KImageNamed(@"ioc_video_bottom_bg");
        [v_image addSubview:v_foot];
 
        v_seeView = [[UIView alloc]init];
        v_seeView.backgroundColor = ColorHex_Alpha(@"000000", 0.72);
        v_seeView.hidden = YES;
        [v_image addSubview:v_seeView];
        
        v_seeLabel = [[UILabel alloc]init];
        v_seeLabel.textColor = [UIColor whiteColor];
        v_seeLabel.font = Font(14);
        [v_seeView addSubview:v_seeLabel];
        
        v_top = [[UILabel alloc]init];
        v_top.backgroundColor = MainColor;
        v_top.layer.cornerRadius = 3;
        v_top.clipsToBounds = YES;
        v_top.font = Font(12);
        v_top.textColor = [UIColor whiteColor];
        v_top.textAlignment = NSTextAlignmentCenter;
        [v_image addSubview:v_top];
        
        v_type = [[UIImageView alloc]init];
        [v_image addSubview:v_type];
        
        v_number = [[UILabel alloc]init];
        v_number.textColor = [UIColor whiteColor];
        v_number.font = Font(13);
        [v_image addSubview:v_number];
        
        [v_image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(0);
        }];
        [v_foot mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.left.mas_offset(0);
            make.bottom.mas_offset(0);
            make.height.mas_offset(60);
        }];
        [v_seeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(0);
        }];
        [v_seeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_offset(0);
        }];
        
        [v_top mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.mas_offset(5);
            make.width.mas_offset(52);
            make.height.mas_offset(22);
        }];
        
        [v_type mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(10);
            make.bottom.mas_offset(-5);
            make.width.height.mas_offset(15);
        }];
        [v_number mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(v_type.mas_right).mas_offset(3);
            make.bottom.mas_offset(-5);
            make.right.mas_lessThanOrEqualTo(-10);
            make.height.mas_offset(15);
        }];
        
        v_top.hidden = YES;
        v_type.image = KImageNamed(@"ico_cell_play");
    UIButton * textShowButtonTo1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        NSString * textShowButtonTitleTo1 = @"测试功能";
        [textShowButtonTo1 setTitle:textShowButtonTitleTo1 forState:UIControlStateNormal];
        NSInteger textShowArcTo1 = arc4random_uniform(22);
        NSLog(@"随机数：%ld", (long)textShowArcTo1);
        
        v_seeLabel.text = @"刚刚看过";
    }
    return self;
}
- (void)setVideoModel:(QZVideoModel *)videoModel{
    _videoModel = videoModel;
    if(videoModel.is_old_see){
        v_seeView.hidden = NO;
    }else{
        v_seeView.hidden = YES;
    }
    if(videoModel.isMyVideo){
        v_type.image = KImageNamed(@"ico_cell_play");
        if([videoModel.ischeck intValue] == 2){
            v_number.text = @"视频审核中";
        }else if([videoModel.ischeck intValue] == 0){
            v_number.text = @"视频审核不通过";
        }else if([videoModel.ischeck intValue] == 1){
            v_number.text = [Tools NumberToShowString:[videoModel.pv integerValue]];
        }
    }else{
        v_type.image = KImageNamed(@"favbefore");
        v_number.text = [Tools NumberToShowString:[videoModel.like_num integerValue]];
    }
    [v_image sd_setImageWithURL:KUrlString(videoModel.image) placeholderImage:v_image.image];
    
}
- (void)showTextViewSubViewToViewTo2:(UIView * )subView{

    UIView * showTextViewSubViewTo2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewSubViewTo2.clipsToBounds = YES;
    [subView addSubview:showTextViewSubViewTo2];
    UILabel * showTextViewSubViewLabelTo3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    showTextViewSubViewLabelTo3.text = @"ppppp88888";
    [showTextViewSubViewTo2 addSubview:showTextViewSubViewLabelTo3];
    
    UIImageView * showTextViewSubViewTo3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [subView addSubview:showTextViewSubViewTo3];

}
@end
